﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Cafe.BusinessLogic;
using DevExpress.XtraEditors;
using Cafe.Presentation;
namespace Cafe
{
    static class Program
    {
        public static CafeManagementService cafeService = new CafeManagementService("Kid", "000000");
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            LoginForm lf = new LoginForm();
            while (lf.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    cafeService = new CafeManagementService(lf.UserName, lf.PassWord);
                    break;
                }
                catch (UserNotFoundException)
                {
                    XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không hợp lệ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (cafeService != null)
            {
                Application.Run(new MainForm());
            }
        }
    }
}
